package main

import (
	"fmt"
	"io"
	"net"
)

func main() {
	var (
		//host          = "www.apache.org"
		//port          = "80"
		//remote        = host + ":" + port
		remote1        = "127.0.0.1:9898"
		msg    string = "GET / \ncontent-length:100\naccept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\naccept-encoding:gzip, deflate, sdch, br\naccept-language:zh-CN,zh;q=0.8,zh-TW;q=0.6,en;q=0.4\navail-dictionary:3GC5dhWe\ncache-control:max-age=0\ncookie:NID=103=Ot1VvG9UKh9Na_3r6c20ZCM9Fj7XF3ANsXW6CArAznVZWkcBtRN97IWtERmSZq28uBDz2Sli6EMY3q8Ow3dbF2EsQm8R0r6ihmST-wnwjf0lD1R4KfNDH4dth4sVjjEez4ljVgg\nupgrade-insecure-requests:1\nuser-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36\nx-chrome-uma-enabled:1\nx-client-data:CLG1yQEIh7bJAQiltskBCMG2yQEI/JnKAQj7nMoBCKmdygE=\n"
		data          = make([]uint8, 4096)
		read          = true
		count         = 0
	)
	// 创建一个socket
	con, err := net.Dial("tcp", remote1)
	// 发送我们的消息，一个http GET请求
	io.WriteString(con, msg)
	// 读取服务器的响应
	for read {
		count, err = con.Read(data)
		read = (err == nil)
		fmt.Printf(string(data[0:count]))
	}
	con.Close()
}
